package com.ruoyi.waterPrice.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.business.waterPrice.WiFarmbookR;
import com.ruoyi.waterPrice.service.IWiFarmbookRService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 农户缴费流水账Controller
 * 
 * @author ps
 * @date 2023-02-17
 */
@RestController
@RequestMapping("/WiFarmbookR")
public class WiFarmbookRController extends BaseController
{
    @Autowired
    private IWiFarmbookRService wiFarmbookRService;

    /**
     * 查询农户缴费流水账列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WiFarmbookR wiFarmbookR)
    {
        startPage();
        List<WiFarmbookR> list = wiFarmbookRService.selectWiFarmbookRList(wiFarmbookR);
        System.out.println(">>>>>>>>>>"+list.size());
        return getDataTable(list);
    }

    /**
     * 导出农户缴费流水账列表
     */
    @RequiresPermissions("waterPrice:WiFarmbookR:export")
    @Log(title = "农户缴费流水账", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WiFarmbookR wiFarmbookR)
    {
        List<WiFarmbookR> list = wiFarmbookRService.selectWiFarmbookRList(wiFarmbookR);
        ExcelUtil<WiFarmbookR> util = new ExcelUtil<WiFarmbookR>(WiFarmbookR.class);
        util.exportExcel(response, list, "农户缴费流水账数据");
    }

    /**
     * 获取农户缴费流水账详细信息
     */
    @GetMapping(value = "/{feeYr}")
    public AjaxResult getInfo(@PathVariable("feeYr") String feeYr)
    {
        return success(wiFarmbookRService.selectWiFarmbookRByFeeYr(feeYr));
    }

    /**
     * 新增农户缴费流水账
     */

    @Log(title = "农户缴费流水账", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WiFarmbookR wiFarmbookR)
    {
        return toAjax(wiFarmbookRService.insertWiFarmbookR(wiFarmbookR));
    }

    /**
     * 修改农户缴费流水账
     */

    @Log(title = "农户缴费流水账", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WiFarmbookR wiFarmbookR)
    {
        return toAjax(wiFarmbookRService.updateWiFarmbookR(wiFarmbookR));
    }

    /**
     * 删除农户缴费流水账
     */

    @Log(title = "农户缴费流水账", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feeYrs}")
    public AjaxResult remove(@PathVariable String[] feeYrs)
    {
        return toAjax(wiFarmbookRService.deleteWiFarmbookRByFeeYrs(feeYrs));
    }
}
